.class public Lcom/zuiapps/suite/utils/string/TextUtils;
.super Ljava/lang/Object;
.source "TextUtils.java"


# static fields
.field private static final NAME_MATCHER:Ljava/util/regex/Pattern;

.field private static final NAME_MATCHER_MATCH_FILTER:Landroid/text/util/Linkify$MatchFilter;

.field private static final NAME_MATCHER_TRANSFORM_FILTER:Landroid/text/util/Linkify$TransformFilter;

.field private static final TWITTA_USER_URL:Ljava/lang/String; = "twitta://users/"

.field private static USER_LINK:Ljava/util/regex/Pattern;

.field private static _userLinkMapping:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .registers 1

    .prologue
    .line 28
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    sput-object v0, Lcom/zuiapps/suite/utils/string/TextUtils;->_userLinkMapping:Ljava/util/HashMap;

    .line 29
    const-string v0, "@.+?\\s"

    invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v0

    sput-object v0, Lcom/zuiapps/suite/utils/string/TextUtils;->NAME_MATCHER:Ljava/util/regex/Pattern;

    .line 30
    new-instance v0, Lcom/zuiapps/suite/utils/string/TextUtils$1;

    invoke-direct {v0}, Lcom/zuiapps/suite/utils/string/TextUtils$1;-><init>()V

    sput-object v0, Lcom/zuiapps/suite/utils/string/TextUtils;->NAME_MATCHER_MATCH_FILTER:Landroid/text/util/Linkify$MatchFilter;

    .line 39
    new-instance v0, Lcom/zuiapps/suite/utils/string/TextUtils$2;

    invoke-direct {v0}, Lcom/zuiapps/suite/utils/string/TextUtils$2;-><init>()V

    sput-object v0, Lcom/zuiapps/suite/utils/string/TextUtils;->NAME_MATCHER_TRANSFORM_FILTER:Landroid/text/util/Linkify$TransformFilter;

    .line 62
    const-string v0, "@<a href=\"http:\\/\\/fanfou\\.com\\/(.*?)\" class=\"former\">(.*?)<\\/a>"

    invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v0

    sput-object v0, Lcom/zuiapps/suite/utils/string/TextUtils;->USER_LINK:Ljava/util/regex/Pattern;

    return-void
.end method

.method public constructor <init>()V
    .registers 1

    .prologue
    .line 14
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method static synthetic access$000()Ljava/util/HashMap;
    .registers 1

    .prologue
    .line 14
    sget-object v0, Lcom/zuiapps/suite/utils/string/TextUtils;->_userLinkMapping:Ljava/util/HashMap;

    return-object v0
.end method

.method public static getMentions(Ljava/lang/String;)Ljava/util/List;
    .registers 9
    .param p0, "msg"    # Ljava/lang/String;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Ljava/util/List",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .prologue
    const/4 v7, 0x1

    .line 89
    new-instance v3, Ljava/util/ArrayList;

    invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V

    .line 91
    .local v3, "mentionList":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Ljava/lang/String;>;"
    const-string v5, "@(.*?)\\s"

    invoke-static {v5}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v4

    .line 92
    .local v4, "p":Ljava/util/regex/Pattern;
    const/16 v0, 0xc

    .line 94
    .local v0, "MAX_NAME_LENGTH":I
    invoke-virtual {v4, p0}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v1

    .line 95
    .local v1, "m":Ljava/util/regex/Matcher;
    :cond_12
    :goto_12
    invoke-virtual {v1}, Ljava/util/regex/Matcher;->find()Z

    move-result v5

    if-eqz v5, :cond_32

    .line 96
    invoke-virtual {v1, v7}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v2

    .line 99
    .local v2, "mention":Ljava/lang/String;
    invoke-virtual {v2}, Ljava/lang/String;->length()I

    move-result v5

    const/16 v6, 0xd

    if-gt v5, v6, :cond_12

    .line 101
    invoke-virtual {v3, v2}, Ljava/util/ArrayList;->contains(Ljava/lang/Object;)Z

    move-result v5

    if-nez v5, :cond_12

    .line 102
    invoke-virtual {v1, v7}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v3, v5}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    goto :goto_12

    .line 106
    .end local v2    # "mention":Ljava/lang/String;
    :cond_32
    return-object v3
.end method

.method public static linkifyUsers(Landroid/widget/TextView;)V
    .registers 5
    .param p0, "view"    # Landroid/widget/TextView;

    .prologue
    .line 51
    sget-object v0, Lcom/zuiapps/suite/utils/string/TextUtils;->NAME_MATCHER:Ljava/util/regex/Pattern;

    const-string v1, "twitta://users/"

    sget-object v2, Lcom/zuiapps/suite/utils/string/TextUtils;->NAME_MATCHER_MATCH_FILTER:Landroid/text/util/Linkify$MatchFilter;

    sget-object v3, Lcom/zuiapps/suite/utils/string/TextUtils;->NAME_MATCHER_TRANSFORM_FILTER:Landroid/text/util/Linkify$TransformFilter;

    invoke-static {p0, v0, v1, v2, v3}, Landroid/text/util/Linkify;->addLinks(Landroid/widget/TextView;Ljava/util/regex/Pattern;Ljava/lang/String;Landroid/text/util/Linkify$MatchFilter;Landroid/text/util/Linkify$TransformFilter;)V

    .line 52
    return-void
.end method

.method private static preprocessText(Ljava/lang/String;)Ljava/lang/String;
    .registers 6
    .param p0, "text"    # Ljava/lang/String;

    .prologue
    .line 66
    sget-object v2, Lcom/zuiapps/suite/utils/string/TextUtils;->USER_LINK:Ljava/util/regex/Pattern;

    invoke-virtual {v2, p0}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v0

    .line 67
    .local v0, "m":Ljava/util/regex/Matcher;
    :goto_6
    invoke-virtual {v0}, Ljava/util/regex/Matcher;->find()Z

    move-result v2

    if-eqz v2, :cond_1c

    .line 68
    sget-object v2, Lcom/zuiapps/suite/utils/string/TextUtils;->_userLinkMapping:Ljava/util/HashMap;

    const/4 v3, 0x2

    invoke-virtual {v0, v3}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v3

    const/4 v4, 0x1

    invoke-virtual {v0, v4}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v2, v3, v4}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    goto :goto_6

    .line 72
    :cond_1c
    new-instance v1, Ljava/lang/StringBuffer;

    invoke-direct {v1}, Ljava/lang/StringBuffer;-><init>()V

    .line 73
    .local v1, "sb":Ljava/lang/StringBuffer;
    sget-object v2, Lcom/zuiapps/suite/utils/string/TextUtils;->USER_LINK:Ljava/util/regex/Pattern;

    invoke-virtual {v2, p0}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v0

    .line 74
    :goto_27
    invoke-virtual {v0}, Ljava/util/regex/Matcher;->find()Z

    move-result v2

    if-eqz v2, :cond_33

    .line 75
    const-string v2, "@$2"

    invoke-virtual {v0, v1, v2}, Ljava/util/regex/Matcher;->appendReplacement(Ljava/lang/StringBuffer;Ljava/lang/String;)Ljava/util/regex/Matcher;

    goto :goto_27

    .line 77
    :cond_33
    invoke-virtual {v0, v1}, Ljava/util/regex/Matcher;->appendTail(Ljava/lang/StringBuffer;)Ljava/lang/StringBuffer;

    .line 78
    invoke-virtual {v1}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v2

    return-object v2
.end method

.method public static setTweetText(Landroid/widget/TextView;Ljava/lang/String;)V
    .registers 5
    .param p0, "textView"    # Landroid/widget/TextView;
    .param p1, "text"    # Ljava/lang/String;

    .prologue
    .line 55
    invoke-static {p1}, Lcom/zuiapps/suite/utils/string/TextUtils;->preprocessText(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 56
    .local v0, "processedText":Ljava/lang/String;
    invoke-static {v0}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v1

    sget-object v2, Landroid/widget/TextView$BufferType;->SPANNABLE:Landroid/widget/TextView$BufferType;

    invoke-virtual {p0, v1, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;Landroid/widget/TextView$BufferType;)V

    .line 57
    const/4 v1, 0x3

    invoke-static {p0, v1}, Landroid/text/util/Linkify;->addLinks(Landroid/widget/TextView;I)Z

    .line 58
    invoke-static {p0}, Lcom/zuiapps/suite/utils/string/TextUtils;->linkifyUsers(Landroid/widget/TextView;)V

    .line 59
    sget-object v1, Lcom/zuiapps/suite/utils/string/TextUtils;->_userLinkMapping:Ljava/util/HashMap;

    invoke-virtual {v1}, Ljava/util/HashMap;->clear()V

    .line 60
    return-void
.end method

.method public static unicodeToString(Ljava/lang/String;)Ljava/lang/String;
    .registers 7
    .param p0, "str"    # Ljava/lang/String;

    .prologue
    .line 17
    const-string v3, "(\\\\u(\\p{XDigit}{4}))"

    invoke-static {v3}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v2

    .line 18
    .local v2, "pattern":Ljava/util/regex/Pattern;
    invoke-virtual {v2, p0}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v1

    .line 20
    .local v1, "matcher":Ljava/util/regex/Matcher;
    :goto_a
    invoke-virtual {v1}, Ljava/util/regex/Matcher;->find()Z

    move-result v3

    if-eqz v3, :cond_39

    .line 21
    const/4 v3, 0x2

    invoke-virtual {v1, v3}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v3

    const/16 v4, 0x10

    invoke-static {v3, v4}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;I)I

    move-result v3

    int-to-char v0, v3

    .line 22
    .local v0, "ch":C
    const/4 v3, 0x1

    invoke-virtual {v1, v3}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v3

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v4, v0}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

    move-result-object v4

    const-string v5, ""

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {p0, v3, v4}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object p0

    goto :goto_a

    .line 24
    .end local v0    # "ch":C
    :cond_39
    return-object p0
.end method
